package allwe;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Test01 {
    public static void main(String[] args) {

        HashMap<String, Integer> map1 = new HashMap<>();
        Map<String, Integer> map = Collections.synchronizedMap(map1);

        //创建10个线程
        for (int i = 0; i < 10; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    long start = System.currentTimeMillis();
                    for (int j = 0; j < 1000000; j++) {
                        map.put("test" + j , j );
                    }
                    long end = System.currentTimeMillis();
                    System.out.println("===============:" + (end - start));
                }
            }).start();
        }
    }
}
